<!DOCTYPE html>
<html>
  <head>
    <title>login.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  <script type="text/javascript" src="../js/jquery-easyui-1.3/jquery-1.7.2.min.js" charset="utf-8"></script>
  <script type="text/javascript" src="../js/jquery-easyui-1.3/jquery.easyui.min.js" charset="utf-8"></script>
  <script type="text/javascript" src="../js/jquery-easyui-1.3/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
  <link rel="stylesheet" href="../js/jquery-easyui-1.3/themes/icon.css" type="text/css"></link>
  <link rel="stylesheet" href="../js/jquery-easyui-1.3/themes/default/easyui.css" type="text/css"></link>
  <script type="text/javascript" charset="utf-8">
  var loginAndRegDialog,regDialog,loginForm;
  $(function(){
	  regDialog = $('#regDialog').show().dialog(
	    {
		 modal : true,
		 closed : false,
	   title : '<center>注册</center>',
	   buttons:[{
		   text : '注册' , handler : function (){   
	     }
	   }]
	   });
	  regDialog.dialog('close');
	  loginAndRegDialog = $('#loginAndRegDialog').dialog({
		  closable : false,
		  modal : true,
		  title :'<center>用户登录</center>',
		  buttons : [{text : '注册',
			  handler : function(){
				  regDialog.dialog('open'); 
			  }
		  },{
			  text : '登录',handler : function(){
			/*	  $.ajax({
					  url :'../servlet/LoginServlet',
					  data : 
						  $('#loginForm').serialize(),
						 //{ name : $('#loginForm input[name=name]').val(),
						  //upassword : $('#loginForm input[name=upassword]').val()
						  //},
						  cache : false,
						dateType : 'json',
					  success: function(r){
						  console.info("成功");
						  console.info(r.msg);
						  if(r && r.success){
							  loginAndRegDialog.dialog('close');
							  $.messager.show({
								  title : '欢迎回来',
								  msg: '您上次登陆时间为:<br/>'+(1900+new Date().getYear())+'-'+new Date().getMonth()+'-'+new Date().getDay()
								  });
						  }else if(r && !r.success){
							  $.messager.alert('提示',r.msg);
						  }
					  },
					  error: function(r){
						  console.info("错误");
						  console.info(r);
					  } 
				  });*/
				  loginForm = $('#loginForm').form({
					  url : "..//servlet/LoginServlet",
					  success : function(r){
						  r = $.parseJSON(r);
						  if(r && r.success){
							  loginAndRegDialog.dialog('close');
							  $.messager.show({
								  title : '欢迎回来',
								  msg: '您上次登陆时间为:<br/>'+(1900+new Date().getYear())+'-'+new Date().getMonth()+'-'+new Date().getDay()
								  });
						  }else{
							  $.messager.alert('提示',r.msg);
						  }
					  }
				  });
				  loginForm.submit();
			  }
		  }]
	  });
  });
  </script>
  </head>
  
  <body>
    <div id="loginAndRegDialog" style="width:300px;higth:200px">
    <form id="loginForm">
	    <table>
	    <tr><th align="right">用户名</th><td><input type="text" name="name" class="easyui-validatebox" data-options="required:true,validType:'length[6,20]'" missingMessage="请输入用户名" invalidMessage="长度必须大于{0}"/>  
</td></tr>
	    <tr><th align="right">密码</th><td><input type="password" name="upassword" class="easyui-validatebox" data-options="required:true,validType:'length[6,20]'" missingMessage="请输入密码" /></td></tr>
	    </table>
    </form>
    </div>
    
    <div id="regDialog" style="width:300px;higth:400px;display:none">
    <form id="regForm">
	    <table>
	    <tr><th align="right">用户名</th><td><input type="text" name="name" class="easyui-validatebox" data-options="required:true,validType:'length[6,20]'" missingMessage="请输入用户名"/></td></tr>
	    <tr><th align="right">密码</th><td><input type="password" name="upassword" class="easyui-validatebox" data-options="required:true,validType:'length[6,20]'" missingMessage="请输入密码"/></td></tr>
	    <tr><th align="right">重复密码</th><td><input type="password" name="reupassword" class="easyui-validatebox" data-options="required:true,validType:'length[6,20]'" missingMessage="请输入重复密码"/></td></tr>
	    <tr><th align="right">真实姓名</th><td><input type="password" name="realname" class="easyui-validatebox" data-options="required:true" missingMessage="请输入真实姓名"/></td></tr>
	    </table>
    </form>
    </div>
  </body>
</html>
